//1.获取样式
const getStyle = (obj, attr) => {
    if (obj.currentStyle) {//ie 6 7 8
        return obj.currentStyle[attr];
    }
    // google
    return window.getComputedStyle(obj, null)[attr];
}
//attribute left top
const animate = (oEle, attr, target) => {
    clearInterval(oEle.timer);
    oEle.timer = setInterval(() => {
        //1.当前位置
        let current = parseInt(getStyle(oEle, attr));
        //2.步长  
        let steps = target > current ? 10 : -10;
        //3. 新的位置=当前位置+步长
        oEle.style[attr] = current + steps + 'px';

        //4.如果剩下的路,不足一步,清空定时器
        if (Math.abs(target - current) <= Math.abs(steps)) {
            clearInterval(oEle.timer);
            oEle.style[attr] = target + "px";
        }
    }, 10)
}